package com.util.vmwareops;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.HashMap;
import java.sql.Connection;
import java.sql.Statement;
import java.util.List;

public class VCConnectionPoolFactory {
    private static HashMap<String, VCConnectionPool> vc = null;
    private VCConnectionPoolFactory() {}
    private static void getVCInfo(List<VCenterInfo> vcInfos) {
        for(VCenterInfo vcInfo : vcInfos) {
            vc.put(
                    vcInfo.getName(),
                    new VCConnectionPool(
                            vcInfo.getHostname(),
                            vcInfo.getPort(),
                            vcInfo.getUsername(),
                            vcInfo.getPassword()
                    )
            );
        }
    }
    public synchronized  static VCConnectionPool getVCConnectionPoolByVCInfo(VCenterInfo vcInfo) {
        return new VCConnectionPool(
                vcInfo.getHostname(),
                vcInfo.getPort(),
                vcInfo.getUsername(),
                vcInfo.getPassword()
        );
    }
    public synchronized static HashMap<String, VCConnectionPool> getAllVCConnectionPool(List<VCenterInfo> vcInfos) {
        if(vc == null) {
            vc = new HashMap<String, VCConnectionPool>();
            getVCInfo(vcInfos);
        }
        return vc;
    }
}
